<?
if ($deleteWhat == "location") {
	// Get contact ID's for this location
	$sql = "SELECT * from oa_btb_Sites WHERE Site_PID = '$deleteID'";
	$result = mysql_db_query($dbname,$sql);
	$row = mysql_fetch_assoc($result);
	$cID1 = $row[SiteContact1_ID];
	$cID2 = $row[SiteContact2_ID];
	
	if (!empty($cID1)) {
		$sql = "DELETE from oa_btb_Contacts WHERE Contact_PID = '$cID1'";
		$result = mysql_db_query($dbname,$sql);
	}
	if (!empty($cID2)) {
		$sql = "DELETE from oa_btb_Contacts WHERE Contact_PID = '$cID2'";
		$result = mysql_db_query($dbname,$sql);
	}
	
	// Delete Site
	$sql = "DELETE from oa_btb_Sites WHERE Site_PID = '$deleteID'";
	$result = mysql_db_query($dbname,$sql);

} elseif ($deleteWhat == "product") {
	// Get contact ID
	$sql = "SELECT ProductContact_ID from oa_btb_Products WHERE Product_PID = '$deleteID'";
	$result = mysql_db_query($dbname,$sql);
	$row = mysql_fetch_row($result);
	$cID = $row[0];
	
	// Delete contact
	$sql = "DELETE from oa_btb_Contacts WHERE Contact_PID = '$cID'";
	$result = mysql_db_query($dbname,$sql);
	
	// Delete product record
	$sql = "DELETE from oa_btb_Products WHERE Product_PID = '$deleteID'";
	$result = mysql_db_query($dbname,$sql);
}
?>
